<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}

if($_POST['sub']!=''){

    $id=empty($_POST['id'])?0:(int)$_POST['id'];
	unset($_POST['id']);
	unset($_POST['sub']);
	$data=array('title'=>$_POST['title'],"width"=>intval($_POST["width"]),"height"=>intval($_POST["height"]),"type"=>$_POST["type"],"description"=>trim($_POST["description"]));
    if(trim($_POST['title'])==""){
        jumpajax('300','广告位名称不能为空','');
    }
 	if($id==0){
	    $id=$ezhand->insert("advtype",$data);
		jumpajax('200','保存成功','','closeCurrent');
	}
	else{
	    $ezhand->update("advtype",$data,'id="'.$id.'"');
		jumpajax('200','修改成功','','closeCurrent');
	}
}
else{
	$id=empty($_GET['id'])?0:(int)$_GET['id'];
	
    if($id==0){
	    $row=array();
	}
	else{
	    $row=$ezhand->select("advtype",'*','id="'.$id.'"');
	}
}
?>